from django.db import models
from utils.BaseModel import BaseModel
# Create your models here.
class CateModle(BaseModel):
    name=models.CharField(max_length=100,verbose_name="课程类别")
    parent=models.ForeignKey("self",on_delete=models.CASCADE,verbose_name="父类别",related_name="son")
    recommend=models.BooleanField(default=True,verbose_name="是否推荐")
    ishot=models.BooleanField(default=True,verbose_name="是否热门")
    isgoods=models.BooleanField(default=True,verbose_name="是否精品")
    class Meta:
        db_table="fgcate"
    def __str__(self):
        return self.name


class Teacher(BaseModel):
    name=models.CharField(max_length=100,verbose_name="教师姓名")
    image=models.ImageField(upload_to="teacher",verbose_name="教师头像")
    jobtitle=models.CharField(max_length=100,verbose_name="教师职称")
    intro=models.TextField(verbose_name="教师简介")
    seles=models.IntegerField(verbose_name="销量")
    class Meta:
        db_table="teacher"
    def __str__(self):
        return self.name

class Course(BaseModel):
    name=models.CharField(max_length=100,verbose_name="课程名称")
    image=models.ImageField(upload_to="course",verbose_name="课程图片")
    price=models.DecimalField(max_digits=10,decimal_places=2,verbose_name="课程价格")
    category=models.ForeignKey(CateModle,on_delete=models.CASCADE,verbose_name="课程分类")
    teacher=models.ForeignKey(Teacher,on_delete=models.CASCADE,verbose_name="授课教师")
    intro = models.CharField(max_length=10,verbose_name="课程简介")
    level=models.CharField(max_length=100,verbose_name="课程难度",choices=((0,"初级"),(1,"中级"),(2,"高级")))
    ishome=models.BooleanField(default=True,verbose_name="是否首页推荐")
    numbers=models.IntegerField(verbose_name="课程人数",default=0)
    video=models.CharField(verbose_name="视频",max_length=200,default="http://127.0.0.1:8000/uploads/course/video/1.mp4")
    class Meta:
        db_table="course"
    def __str__(self):
        return self.name



